<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>新增/修改栏目</title>
    {sys:load href="admin/css/bootstrap.min.css,admin/css/materialdesignicons.min.css,admin/css/style.min.css,admin/lib/layui/css/layui.css"}
</head>

<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">

                    <form action="/app/cms/admin.column/savedata" method="post" class="row" id="column">
                        <div class="form-group col-md-12">
                            <label for="title">栏目标题:</label>
                            <input type="text" class="form-control" id="title" name="title" value="{$detail.title}" placeholder="" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-12">
                            <label for="sub_title">栏目副标题:</label>
                            <input type="text" class="form-control" id="sub_title" name="sub_title" value="{$detail.sub_title}" placeholder="" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-12">
                            <label for="pid">上级栏目:</label>
                            {php} $columns = \appin\cms\model\Column::field('id,pid,title')->where('pid',0)->select();{/php}
                            <select class="form-control" id="pid" name="pid" size="1">
                                <option value="0">作为一级栏目</option>
                                {volist name="columns" id="column"}
                                <option value="{$column.id}" {if condition="$detail['pid'] == $column.id"} selected {/if}>{$column.title}</option>
                                {volist name="column.son" id="col"}
                                <option value="{$col.id}" {if condition="$detail['pid'] == $col.id"} selected {/if}> &nbsp;&nbsp; --- {$col.title}</option>
                                {volist name="col.son" id="colson"}
                                <option value="{$colson.id}" {if condition="$detail['pid'] == $colson.id"} selected {/if}> &nbsp;&nbsp;&nbsp;&nbsp; --- {$colson.title}</option>
                                {/volist}
                                {/volist}
                                {/volist}
                            </select>
                        </div>

                        <div class="form-group col-md-12">
                            <label for="type">栏目类型:</label>
                            <div class="controls-box">
                                <small class="help-block"></small>
                                {php} $modes = new \appin\cms\model\Column(); {/php}
                                {foreach $modes->mode as $key=>$val}
                                <label class="lyear-radio radio-inline radio-primary">
                                    <input type="radio" name="mode" value="{$key}" {if condition="$detail.mode eq $key"}checked{/if}><span>{$val}</span>
                                </label>
                                {/foreach}
                            </div>
                        </div>

                        <div class="form-group col-md-12">
                            <label for="image">栏目图片:</label>
                            <div class="input-group">
                                <input type="text" class="form-control" name="image" id="image" value="{$detail.image}" />
                                <div class="input-group-btn"><button class="btn btn-default upload" type="button">上传图片</button></div>
                            </div>
                        </div>

                        <div class="form-group col-md-12">
                            <label for="status">显示位置:</label>
                            <div class="controls-box">
                                <small class="help-block"></small>
                                {foreach $modes->status as $key=>$val}
                                <label class="lyear-radio radio-inline radio-primary">
                                    <input type="radio" name="status" value="{$key}" {if condition="$detail.status eq $key"}checked{/if}><span>{$val}</span>
                                </label>
                                {/foreach}
                            </div>
                        </div>

                        <div class="form-group col-md-4">
                            <label for="href">跳转地址:</label>
                            <input type="text" class="form-control" id="href" name="href" value="{$detail.href}" placeholder="" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-3">
                            <label for="alias">url 访问别名:</label>
                            <input type="text" class="form-control" id="alias" name="alias" value="{$detail.alias}" placeholder="" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-3">
                            <label for="template">自定义模板文件:</label>
                            <input type="text" class="form-control" id="template" name="template" value="{$detail.template}" placeholder="留空使用默认模板文件" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-2">
                            <label for="sort">排序:</label>
                            <input type="text" class="form-control" id="sort" name="sort" value="{$detail.sort}" placeholder="" autocomplete="off" />
                        </div>
                        <!--
                        <div class="form-group col-md-12">
                          <label for="type">栏目内容:</label>
                           <textarea name="content" id="container" style="width:100%;min-height:300px">{:$detail['content']}</textarea>
                        </div>
                        -->
                        <div class="form-group col-md-12">
                            <label for="type">栏目内容:</label>
                            <textarea name="content" id="container" style="width:100%;min-height:300px">{:$detail['content']}</textarea>
                        </div>

                        <div class="form-group col-md-4">
                            <label for="seo_title">SEO 标题:</label>
                            <input type="text" class="form-control" id="seo_title" name="seo_title" value="{$detail.seo_title}" placeholder="" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-8">
                            <label for="seo_keyword">SEO 关键字:</label>
                            <input type="text" class="form-control" id="seo_keyword" name="seo_keyword" value="{$detail.seo_keyword}" placeholder="" autocomplete="off" />
                        </div>

                        <div class="form-group col-md-12">
                            <label for="seo_desc">SEO 描述:</label>
                            <textarea class="form-control" id="seo_desc" rows="5" name="seo_desc" placeholder="" >{$detail.seo_desc}</textarea>
                        </div>

                        <div class="form-group col-md-12">
                            <input type="hidden" name="lang_id" value="{$Request.session.admin.lang.id}" />
                            <input type="hidden" name="id" value="{$detail.id}" />
                            <button type="button" class="btn btn-primary btn-submit" form-id="column">确 定</button>
                        </div>
                    </form>

                </div>
            </div>
        </div>

    </div>
</div>
{sys:load href="admin/lib/layui/layui.js,admin/common.js,admin/lib/ueditor/ueditor.config.js,admin/lib/ueditor/ueditor.all.min.js"}
<script type="text/javascript">
    UE.delEditor('container');
    var ue = UE.getEditor('container',{
        autoHeight : true,
        serverUrl: "/admin/index/uploaded"
    });

    layui.use(['Request','jquery','layer','laydate','upload'], function(){
        var Request = layui.Request,$ = layui.jquery,layer = layui.layer,laydate = layui.laydate,upload = layui.upload;

        var uploader = upload.render({
            elem: '.upload',
            url: '/admin/index/uploader',
            done: function( response , index, upload ) {
                if ( response.state == 'success' ) {
                    $("#image").val(response.data.path);
                    layer.msg('上传成功!')
                } else {
                    layer.msg( response.message );
                }
            }
        });

        $(".btn-submit").click(function(){
            Request.postInSubmit(".btn-submit", function(response){
                layer.msg('操作成功', {time:2000}, function(){
                    parent.location.reload()
                })
            })
        });
    })
</script>
</body>
</html>
